<template>
  <div class="home-swipe">
    <van-search
      v-model="search"
      placeholder="请输入关键词"
      shape="round"
      @search="onSearch"
      @focus="onFocus"
      input-align="center"
    ></van-search>
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for=" (item,index) in bannerData" :key="index">
        
        <van-image lazy-load :src="item.picUrl" radius="20"/>
        </van-swipe-item>
    </van-swipe>
  </div>
</template>
<style scoped>
.my-swipe .van-swipe-item img{
  /* color: #fff;
  font-size: 20px;
  line-height: 150px;
  text-align: center;
  background-color: #39a9ed; */
  width:100%;
}
</style>
<script>
import { Toast } from "vant";
// import axios from "axios";
export default {
  data() {
    return {
      search: "",
      bannerData: [],
    };
  },
  methods: {
    
    getBanner() {
      this.$request("get",'/recommend/banner').then(res=>{
        console.log(res)
        if(res.result==100){
          this.bannerData = res.data;
        }
      })
      // axios
      //   .get("/api/recommend/banner")
      //   .then((response) => {
      //     let resData = response.data;
      //     if (resData.result == 100) {
      //       this.bannerData = resData.data;
      //     }
      //     console.log(this.bannerData);
      //   })
      //   .catch(function (error) {
      //     console.log(error);
      //   });
    },
    onSearch(val) {
      Toast(val);
    },
    onFocus() {},
  },
  created() {
    this.getBanner();
  },
};
</script>